using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WF1.lab02
{
    public partial class frmAddNewProduct : Form
    {
        public frmAddNewProduct()
        {
            InitializeComponent();
        }

        private void frmAddNewProduct_Load(object sender, EventArgs e)
        {
            cbbUnit.SelectedIndex = 0;
        }

        private void btnViewDetail_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("You must enter product's name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtName.Focus();
            }
            else if(picPicture.Image == null)
            {
                MessageBox.Show("You must select product's picture", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnSelectPicture.Focus();
            }
            else
            {
                frmProductDetail frmDetail = new frmProductDetail(txtName.Text, nmPrice.Value.ToString(), cbbUnit.Text, nmQuantity.Value.ToString(), dtpImportDate.Text, picPicture.Image);
                frmDetail.ShowDialog();
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnSelectPicture_Click(object sender, EventArgs e)
        {
            frmSelectPicture f = new frmSelectPicture(this);
            f.ShowDialog();
        }

        public void SelectPicture(Image img)
        {
            picPicture.Image = img;
        }
    }
}